Operators
Muze provides some operators which is needed to do various operations like creating shared fields or sanitize html strings.
To access operators,
const Operators = muze.Operators;
html
Syntax: html
templateString``
A string template tagged function which sanitizes input html formatted string according to the allowed html tags. This is used to render html in canvas components like title and tooltip.
Parameters:
Property | Type | Required | Default | Description |
---|---|---|---|---|
templateString | Array<string> | true | - | template strings. |
Returns
A function which returns the sanitized html string.
Usage
const env = muze();
const canvas = env.canvas();
canvas.title(html`<span style=font-size:20px;>TITLE</span>`);
share
Syntax: share(...measures)
Creates a new composed variable instance from multiple variables. This is required when we need to map multiple fields in a single axis. For example, we want to show minimum temperature and maximum temperature on y-axis, then we have to create a shared field.
Parameters:
Property | Type | Required | Default | Description |
---|---|---|---|---|
measures | string | true | - | Measure names |
Returns
Variable instance.
Usage
const env = muze();
const canvas = env.canvas();
const { share } = muze.Operators;
const sharedField = share('maxTemp', 'minTemp');
canvas.rows([sharedField])
.columns(['date'])
.mount('#chart');